package com.example.demo.aspect;

import com.example.demo.domain.RequestLog;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.Arrays;

@Aspect
@Component
public class LogAspect {

    private static final Logger logger = LoggerFactory.getLogger(LogAspect.class);

//    @After("execution(* com.example.demo.controller..*.*(..))")
//    public void logBefore(){
//        logger.info("---------------------请求开始---------------------");
//        logger.info("日志业务逻辑处理");
//        logger.info("---------------------请求结束---------------------");
//    }

    @Before("execution (* com.example.demo.controller.*.*(..))")
    public void logBefore(){
        logger.info("-----------------请求开始-----------");
        logger.info("日志业务逻辑处理");
        logger.info("---------------------请求结束---------------------");
    }
}
